package com.taotao.rop.service;

import com.rop.annotation.HttpAction;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import com.taotao.rop.database.domain.WechatRespArticle;
import com.taotao.rop.database.mapper.WechatRespArticleMapper;
import com.taotao.rop.response.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@ServiceMethodBean(httpAction = HttpAction.POST, version = "1.0")
public class WechatRespArticleService {
    @Autowired
    private WechatRespArticleMapper respArticleMapper;

    @ServiceMethod(method = "respArticle.list")
    public Object list(WechatRespArticle request){
        List<WechatRespArticle> list = respArticleMapper.getList(request);

        BaseResponse<List<WechatRespArticle>> response = new BaseResponse<List<WechatRespArticle>>();
        response.setSuccess(true);
        response.setData(list);
        return response;
    }

    @ServiceMethod(method = "respArticle.insert")
    public Object insert(WechatRespArticle request){
        Integer count = respArticleMapper.insertOne(request);

        BaseResponse<Integer> response = new BaseResponse<Integer>();
        response.setSuccess(true);
        response.setData(count);
        return response;
    }

    @ServiceMethod(method = "respArticle.remove")
    public Object remove(WechatRespArticle request){
        Integer count = respArticleMapper.removeOne(request);

        BaseResponse<Integer> response = new BaseResponse<Integer>();
        response.setSuccess(true);
        response.setData(count);
        return response;
    }
}
